import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsInt, IsNotEmpty, MaxLength, MinLength } from "class-validator";
import { PaginatedDto } from "src/common/dto";

export class CreateRoleDto {
    @ApiProperty({ example: '管理员', description: '角色名称' })
    @IsNotEmpty({
        message: '角色名不能为空'
    })
    @MinLength(1)
    @MaxLength(15)
    name: string
}

export class DeleteRoleDto {
    @ApiProperty({ example: '1111', description: '角色id' })
    @IsNotEmpty({
        message: 'id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}

export class UpdateRoleDto {
    @ApiProperty({ example: '1111', description: '角色id' })
    @IsNotEmpty({
        message: 'id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number

    @ApiProperty({ example: '管理员', description: '角色名称' })
    @IsNotEmpty({
        message: '角色名不能为空'
    })
    @MinLength(1)
    @MaxLength(15)
    newName: string

    @ApiProperty({ example: [{ id: 1 }], description: '权限id数组' })
    @IsNotEmpty({
        message: '权限id不能为空'
    })
    permissions: []
}


export class FindManyRoleDto extends PaginatedDto { }